﻿using System;
using System.Diagnostics;
using System.Threading;
using Hydra.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hydra.Test
{
    [TestClass]
    public class StethoscopeTest
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        [TestMethod]
        public void StethoscopeTestMethod()
        {
            // create and start server
            Stethoscope server = new Stethoscope();
            server.Start(Process.GetCurrentProcess().Id);
            log.InfoFormat("WCF server started.");

            // create client and connect to server
            Parasite client = new Parasite();
            client.Connect();
            log.InfoFormat("WCF client connected.");

            // callback
            server.ApplyDetours(new byte[] { 1, 2, 3 });
            server.ApplyDetours(new byte[] { 1, 2, 3, 4 });
            server.ReleaseDetours();

            // disconnect from server
            client.Disconnect();
            log.InfoFormat("WCF client disconnected.");

            // stop server
            server.Stop();
            log.InfoFormat("WCF server stopped.");
        }

        [TestMethod]
        public void GetHashMethod()
        {
            var hash = Util.GetHash(1257);
            log.InfoFormat("Util.GetHash(1257)={0}", hash);
        }
    }
}
